//
//  Eligibility+Eligibility.m
//  ClinicalCollections
//
//  Created by janakiraman gopinath on 5/19/13.
//  Copyright (c) 2013 GOPI. All rights reserved.
//

#import "Eligibility+Eligibility.h"

@implementation Eligibility (Eligibility)

+ (void) eligibility:(NSDictionary *) eligibilities
          forContext:(NSManagedObjectContext *)context
 forClinicalTrialGov:(ClinicalTrialGov *)clinicalTrialGov
{
    
    Eligibility *eligibility = (Eligibility *) [NSEntityDescription insertNewObjectForEntityForName:@"Eligibility"
                                                                             inManagedObjectContext:context];
    eligibility.gender = [eligibilities valueForKey:@"gender"];
    eligibility.minimum_age = [eligibilities valueForKey:@"minimum_age"];
    eligibility.maximum_age = [eligibilities valueForKey:@"maximum_age"];
   // eligibility.study_pop = [eligibilities valueForKey:@"study_pop"];
    if (!([[eligibilities valueForKey:@"sampling_method"] isEqual:[NSNull null]]))
        eligibility.sampling_method = [eligibilities valueForKey:@"sampling_method"];
    eligibility.criteria = [eligibilities valueForKeyPath:@"criteria.textblock"];
    if (!([[eligibilities valueForKey:@"healthy_volunteers"] isEqual:[NSNull null]]))
    eligibility.healthy_volunteers = [eligibilities valueForKeyPath:@"healthy_volunteers"];
    
    eligibility.clinicalTrialGov = clinicalTrialGov;
    
    return;
}

@end
